package org.erpworld.util;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;

/**
 * Author: volkan
 */
public class JsfUtil {
    private static FacesMessage facesMessage;

    public static void addErrorMessage(String mesaj) {
        facesMessage = new FacesMessage(FacesMessage.SEVERITY_ERROR, mesaj, mesaj);
        FacesContext.getCurrentInstance().addMessage("Hata ", facesMessage);
    }

    public static void addInfoMessage(String mesaj) {
        facesMessage = new FacesMessage(FacesMessage.SEVERITY_INFO, mesaj, mesaj);
        FacesContext.getCurrentInstance().addMessage("Başarılı ", facesMessage);
    }
    
    public static  void putFlashScope(String key,Object deger){
        FacesContext.getCurrentInstance().getExternalContext().getFlash().put(key, deger);
    }
    public static String redirect(String target) {
        return target + "?faces-redirect=true";
    }
}
